import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [{
  path: '/login', name: 'login', component: () => import('@/views/login/')
},
{ path: '/search', name: 'search', component: () => import('@/views/search/') },
{ path: '/article/:articleId', name: 'article', props: true, component: () => import('@/views/article/') },
{ path: '/user/profile', name: 'user-profile', component: () => import('@/views/user-profile/') },
{
  path: '/user/chat',
  name: 'user-chat',
  component: () => import('@/views/user-chat/'),
  meta: { requestAuth: true }
},
{
  path: '/',
  redirect: '/home',
  component: () => import('@/views/layout'),
  children: [
    { path: '/home', name: 'home', component: () => import('@/views/home/') },
    { path: '/my', name: 'my', component: () => import('@/views/my/') },
    { path: '/video', component: () => import('@/views/video/') },
    { path: '/qa', component: () => import('@/views/qa/') }
  ]
}
]

const router = new VueRouter({
  routes
})
router.beforeEach((to, from, next) => {
  next()
})

export default router
